import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

//  帶有圖標的組件

class UniversalCardItem extends StatelessWidget {
  final String icon;
  final Widget child;
  final String title;
  final VoidCallback onPress;
  final List phone;
  const UniversalCardItem({Key key, @required this.icon, this.child, this.title, this.onPress, this.phone}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return InkWell(
      onTap: onPress,
      child: Container(
        padding: EdgeInsets.only(top:10),
        child: Row(
          children: <Widget>[
            ImageIcon(
              AssetImage(icon),
              size: ScreenUtil().setWidth(20),
              color: Color(0xffB9BDC5),
            ),
            Padding(
              padding: EdgeInsets.only(left: 10),
            ),
            Expanded(child:child==null?ItemText(title: title):child)
          ],
        ),
      ),
    );
  }

//
  Widget ItemText({@required String title}) {
    return Container(
      alignment: Alignment.centerLeft,
      child: Text(
        title,
        textAlign: TextAlign.left,
        style: TextStyle(
            color: Color(0xffB9BDC5), fontSize: ScreenUtil().setSp(12),
        fontWeight: FontWeight.w500),
        maxLines: 3,
        overflow: TextOverflow.ellipsis,
      ),
    );
  }

}
